<?php
/**
 * Description: 删除错题
 * User: devforma
 * Date: 15/4/29
 * Time: 18:57
 */

class DeleteErrorQuestion implements iController {

    /**
     * api请求处理主函数
     * @param array $queryArgs 就是$_REQUEST变量
     * @return array api返回结果，必须含response_code
     */
    public function output($queryArgs) {
        global $uddb;
        
        if (validateUser($queryArgs) !== 1)
            return genOutput(1000);

        $userId = $queryArgs['user_id'];

        if (empty($queryArgs['question_id']) || !is_numeric($queryArgs['question_id'])) {
            return genOutput(1000);
        }

        //删除错题
        $uddb -> usertestsTable($userId)
            ->where(array('user_id' => $userId, 'question_id' => $queryArgs['question_id']))
            ->update(array('is_right' => 2));
        return genOutput(1);
    }
}